import { request } from "@/request";

export async function fetchList(data) {
  const res = await request("/admin/schoolbag/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}
export async function fetchPackagesList(data) {
  return await request("/admin/schoolbag/listQuery", {
    method: "POST",
    data,
  });
}

export async function add(data) {
  return request("/admin/schoolbag/add", {
    method: "POST",
    data,
  });
}

export async function update(data) {
  return request("/admin/schoolbag/update", {
    method: "POST",
    data,
  });
}

export function remove(data) {
  return request(`/admin/schoolbag/delete?ids=${data.ids}`, {
    method: "POST",
  });
}
export function fetchInfo(data) {
  return request(`/admin/schoolbag/get/${data.id}`, {
    method: "POST",
  });
}
// 书包书籍列表
export async function fetchBooksList(data) {
  const res = await request("/admin/schoolbag/books/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}

export async function fetchBooksRealList(data) {
  return await request("/admin/schoolbag/books/listQuery", {
    method: "POST",
    data,
  });
}

export async function batchAddBook(data) {
  return request("/admin/schoolbag/books/batchAdd", {
    method: "POST",
    data,
  });
}
export async function removeBook(data) {
  return request(`/admin/schoolbag/books/delete?ids=${data.ids}`, {
    method: "POST",
    data,
  });
}

// 库存分页
export async function fetchBookStorageList(data) {
  const res = await request("/admin/schoolbag/booksStorage/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}

export async function addBookStorage(data) {
  return request("/admin/schoolbag/booksStorage/add", {
    method: "POST",
    data,
  });
}

export async function deleteBookStorage(data) {
  return request(`/admin/schoolbag/booksStorage/delete?ids=${data.ids}`, {
    method: "POST",
    data,
  });
}
export async function fetchGroupList(data) {
  const res = await request("/admin/schoolbag/group/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}
export async function addGroup(data) {
  return request("/admin/schoolbag/group/add", {
    method: "POST",
    data,
  });
}

export function removeGroup(data) {
  return request(`/admin/schoolbag/group/delete?ids=${data.ids}`, {
    method: "POST",
  });
}
export function createGroupNo(data) {
  return request(`/admin/schoolbag/groupCode/get/${data.type}`, {
    method: "POST",
  });
}

export function fetchBooksStorageList(data) {
  return request(`/admin/schoolbag/booksStorage/listQuery`, {
    method: "POST",
    data,
  });
}

export function batchAdd(data) {
  return request(`/admin/schoolbag/groupBag/batchAdd`, {
    method: "POST",
    data,
  });
}
export function batchUpdate(data) {
  return request(`/admin/schoolbag/groupBag/batchUpdate`, {
    method: "POST",
    data,
  });
}


export function fetchStorageBooks(data) {
  return request(`/admin/schoolbag/groupBag/get/${data.id}`, {
    method: "POST",
    data,
  });
}

export function validAuditStatus(data) {
  return request(`/admin/schoolbag/validAuditStatus?id=${data.id}`, {
    method: "POST",
    data,
  });
}
export function getBagListByGroupId(data) {
  return request(`/admin/schoolbag/groupBag/getBagListByGroupId/${data.groupId}`, {
    method: "POST",
    data,
  });
}

export function checkGroupBag(data) {
  return request(`/admin/schoolbag/groupBag/check`, {
    method: "POST",
    data,
  });
}



// 书包收货-查询信息
export function fetchPackageInfo(data) {
  return request(`/admin/schoolbag/groupBag`, {
    method: "POST",
    data,
  });
} // 书包收货-确认收货
export function confirmReceipt(data) {
  return request(`/admin/schoolbag/groupBag`, {
    method: "POST",
    data,
  });
}

export async function fetchSpecList(data) {
  const res = await request("/admin/schoolbag/specification/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}
export async function addSpec(data) {
  return request("/admin/schoolbag/specification/add", {
    method: "POST",
    data,
  });
}
export async function updateSpec(data) {
  return request("/admin/schoolbag/specification/update", {
    method: "POST",
    data,
  });
}

export function removeSpec(data) {
  return request(`/admin/schoolbag/specification/delete?ids=${data.ids}`, {
    method: "POST",
  });
}
export function fetchSpecInfo(data) {
  return request(`/admin/schoolbag/specification/get/${data.id}`, {
    method: "POST",
    data,
  });
}

export function updateStatus(data) {
  return request(`/admin/schoolbag/specification/updateStatus`, {
    method: "POST",
    data,
  });
}

